function logindownload(){
$.each($('.popup'), function(index, value) {
var href = $(value).attr("href");
$(value).attr("href","/download/");
$(value).attr("prepare",downloadURL(href));
});
 $(".popup").colorbox({iframe:true, innerWidth:420, innerHeight:334, scrolling:false});
}
function tonormal(){
  $.each($('.popup'), function(index, value) {
 	var result = $(value).attr("prepare");
  	$(value).attr("href",result);
   });
  $.colorbox.remove();  
}
function downloadURL(url ){
var result = url.replace("/resources/","");
result = "/nbodownload/download/?path="+encodeURIComponent(result);
return result;
}
 function twodownload(){
 	$.each($('.popup'), function(index, value) {
 	var href = $(value).attr("href");
  	$(value).attr("href",downloadURL(href));
   });
}
function closePopup(){
  $.colorbox.close();
	tonormal();
}
$(document).ready(function(){
	if ($.colorbox){
  	logindownload();
	}
});